class MajorityElementSolver:
    def solve(self, nums):
        """
        使用Boyer-Moore投票算法找到多数元素
        :param nums: List[int]，输入数组
        :return: int，多数元素
        """
        candidate = None
        count = 0

        for num in nums:
            if count == 0:
                candidate = num
            count += (1 if num == candidate else -1)

        return candidate